using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    public string siteDirName = System.Configuration.ConfigurationManager.AppSettings["siteDirName"].ToString();
    string extension = System.Configuration.ConfigurationManager.AppSettings["extension"].ToString();
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = Application["HomeTitle"].ToString();
    }
    public string getGeneratedScript(string permaLink, object titleObj, string publisher)
    {
        string generated = "<script type=\"text/javascript\">\n";
        generated += "  addthis_url    = '" + permaLink + "';\n";
        generated += "  addthis_title  = '" + titleObj.ToString() + "';\n";
        generated += "  addthis_pub    = '" + publisher + "';\n";
        generated += "</script><script type=\"text/javascript\" src=\"http://s7.addthis.com/js/addthis_widget.php?v=12\" ></script>\n";
        return generated;
    }
    protected void DataList2_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        HtmlInputHidden title = (HtmlInputHidden)e.Item.FindControl("title");
        HtmlInputHidden permaLinkData = (HtmlInputHidden)e.Item.FindControl("permaLink");
        HtmlInputHidden publisher = (HtmlInputHidden)e.Item.FindControl("publisher");
        string permaLinkMain = siteDirName + "Blog/" + permaLinkData.Value + extension;
        Label lblBookmark = (Label)e.Item.FindControl("bookmark1");
        lblBookmark.Text = getGeneratedScript(permaLinkMain, title.Value, publisher.Value);

    }
}
